package com.ruoyi.gwc.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeIDGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gwc.mapper.TApprovalApplyMapper;
import com.ruoyi.gwc.domain.TApprovalApply;
import com.ruoyi.gwc.service.ITApprovalApplyService;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 申请用车审批Service业务层处理
 * 
 * @author wp
 * @date 2024-12-13
 */
@Service
public class TApprovalApplyServiceImpl extends ServiceImpl<TApprovalApplyMapper, TApprovalApply> implements ITApprovalApplyService
{
    @Autowired
    private TApprovalApplyMapper tApprovalApplyMapper;

    /**
     * 查询申请用车审批
     * 
     * @param approvalId 申请用车审批主键
     * @return 申请用车审批
     */
    @Override
    public TApprovalApply selectTApprovalApplyByApprovalId(Long approvalId)
    {
        return tApprovalApplyMapper.selectTApprovalApplyByApprovalId(approvalId);
    }

    /**
     * 查询申请用车审批列表
     * 
     * @param tApprovalApply 申请用车审批
     * @return 申请用车审批
     */
    @Override
    public List<TApprovalApply> selectTApprovalApplyList(TApprovalApply tApprovalApply)
    {
        return tApprovalApplyMapper.selectTApprovalApplyList(tApprovalApply);
    }



    /**
     * 新增申请用车审批
     * 
     * @param tApprovalApply 申请用车审批
     * @return 结果
     */
    @Override
    public int insertTApprovalApply(TApprovalApply tApprovalApply)
    {
        tApprovalApply.setCreateTime(DateUtils.getNowDate());
        tApprovalApply.setCreateBy(getUsername());
        tApprovalApply.setApprovalId(SnowFlakeIDGenerator.getInstance().nextId());
        return tApprovalApplyMapper.insertTApprovalApply(tApprovalApply);
    }

    /**
     * 修改申请用车审批
     * 
     * @param tApprovalApply 申请用车审批
     * @return 结果
     */
    @Override
    public int updateTApprovalApply(TApprovalApply tApprovalApply)
    {
        tApprovalApply.setUpdateTime(DateUtils.getNowDate());
        tApprovalApply.setUpdateBy(getUsername());
        return tApprovalApplyMapper.updateTApprovalApply(tApprovalApply);
    }

    /**
     * 批量删除申请用车审批
     * 
     * @param approvalIds 需要删除的申请用车审批主键
     * @return 结果
     */
    @Override
    public int deleteTApprovalApplyByApprovalIds(Long[] approvalIds)
    {
        return tApprovalApplyMapper.deleteTApprovalApplyByApprovalIds(approvalIds);
    }

    /**
     * 删除申请用车审批信息
     * 
     * @param approvalId 申请用车审批主键
     * @return 结果
     */
    @Override
    public int deleteTApprovalApplyByApprovalId(Long approvalId)
    {
        return tApprovalApplyMapper.deleteTApprovalApplyByApprovalId(approvalId);
    }
}
